Goto

Collaborating Authors

 single responsibility principle


Single Responsibility Principle

#artificialintelligence

SOLID is a mnemonic acronym named by Robert C. Martin used in Software Programming, It represents 5 principles of Object-Oriented Programming. All of them are broadly used and worth knowing. But in this post, I will focus on the first one: the Single Responsibility Principle (SRP). One class should only serve one purpose, this does not imply that each class should have only one method but they should all relate directly to the responsibility of the class. All the functions, methods, and properties should all work towards the same goal.


Ten basic principles of coding

#artificialintelligence

Another one from Uncle Bob, the Single Responsibility Principle dictates that each module is only ever responsible for one thing. To create clear programs and code, the Single Responsibility Principle means for each module to control a single optionality. Your final version of code probably includes main functionality and options. When sharing your code, clearly mark sections of code which should and should not be modified. Open code signals to others that those sections can be modified without breaking the programme, whereas closed code lets others know what not to change.